﻿var EventUtil = {};
EventUtil.addEventHandler = function (a, b, c) {
    if (a.addEventListener)
        a.addEventListener(b, c, false);
    else if (a.attachEvent)
        a.attachEvent("on" + b, c);
    else a["on" + b] = c
};
ScrollCrossTOP = { interval: 0, count: 0, duration: 0, step: 0, srcObj: null, callback: null };
ScrollCrossTOP.doit = function (a, b, c, f) {
    BigNews.OnScrolling = true;
    var d = ScrollCrossTOP;
    d.callback();
    a.style.marginTop = function (g, e, h, j) {
        return h * ((g = g / j - 1) * g * g + 1) + e;
    } (d.count, b, c, f) + "px";
    d.count++;
    if (d.count == f) {
        clearInterval(d.interval);
        d.count = 0;
        a.style.marginTop = b + c + "px";
        BigNews.currentBegin = b + c;
        BigNews.OnScrolling = false;
    }
};

var B = BigNews = { current: 0, next: 0, scrollInterval: 0, autoScroller: 0, s: {}, OnScrolling: false, currentBegin: 0 };
BigNews.turn = function (a, b) {
    clearInterval(BigNews.autoScroller);
    BigNews.scroll(a, b);
};
BigNews.scroll = function (a, b) {
    var c = b.step, f = BigNews;
    f.next = a;
    try {
        clearInterval(BigNews.s.interval)
    } catch (d) { }
    if (b.pictxt != null && b.pictxt != "")
        document.getElementById(b.pictxt + "_" + a).style.display = "block";
    var g = -a + f.current;
    document.getElementById(b.bigpic);
    BigNews.s.duration = 16;
    BigNews.s.callback = function () {
        BigNews.current = a;
        for (i = 0; i < b.totalcount; i++)
            if (i == a)
                document.getElementById("big_pic_nav_" + i).className = "on";
            else
                document.getElementById("big_pic_nav_" + i).className = ""
        };
        var beign = parseInt(BigNews.currentBegin);
        var span = -(a * c + beign);
        var e = parseInt(document.getElementById(b.bigpic).style.marginTop) || 0;

        BigNews.s.interval = setInterval(
			function () {
			    BigNews.s.doit(document.getElementById(b.bigpic), beign, span, 16)
			}, 10);
    };
    BigNews.auto = function (a) {
        clearInterval(BigNews.autoScroller);
        BigNews.autoScroller = setInterval(
			function () {
			    BigNews.scroll(BigNews.current == a.totalcount - 1 ? 0 : BigNews.current + 1, a)
			}, a.autotimeintval)
    };
    BigNews.pauseSwitch = function () { clearTimeout(BigNews.autoScroller) };
    BigNews.showNext = function (a, b) {
        if (a >= MovieRecom.totalcount - 1) {
            document.body.focus();
            return false
        } else {
            BigNews.pauseSwitch();
            BigNews.turn(a + 1, b);
            BigNews.auto(b);
            document.body.focus()
        }
    };
    BigNews.showPre = function (a, b) {
        if (a <= 0) {
            document.body.focus();
            return false
        } else {
            BigNews.pauseSwitch();
            BigNews.turn(a - 1, b);
            BigNews.auto(b);
            document.body.focus()
        }
    };
    BigNews.init = function (a) {
        BigNews.s = ScrollCrossTOP;
        EventUtil.addEventHandler(document.getElementById(a.bigpic), "mouseover", new Function("BigNews.pauseSwitch();"));
        EventUtil.addEventHandler(document.getElementById(a.bigpic), "mouseout", new Function("BigNews.auto(" + a.objname + ");"));
        for (i = 0; i < a.totalcount; i++) {
            a.smallpic != null && a.smallpic != "" && EventUtil.addEventHandler(document.getElementById(a.smallpic + "_" + i), "mouseover", new Function("BigNews.turn(" + i + "," + a.objname + ");BigNews.pauseSwitch();return false;"));
            a.smallpic != null && a.smallpic != "" && EventUtil.addEventHandler(document.getElementById(a.smallpic + "_" + i), "mouseout", new Function("BigNews.auto(" + a.objname + ");return false;"));
        }
        BigNews.auto(a);
    };
